package com.weibo.util;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

public class ImageUtil {

	public static Image getImage(Display device,String name){
		return getImage(device, ClassLoader.getSystemResourceAsStream("com/xwl/util/images/"+name));
	}
	
	public static Image getURLImage(Display device,String name){
		URL imageurl=null;
		try {
			imageurl = new URL(name);
			return getImage(device, imageurl.openStream());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	private static Image getImage(Display device,InputStream is){
		return new Image(device, is);
	}
}
